-<script type="text/javascript">
var quantities=Array();

function getQuantity(id){

	for (var i=0;i<quantities.length;i++)
	{
if (quantities[i].id==id) return quantities[i].quantity;
		}
	return null;
}
  </script>
  


<?php

$articleId=getParameter("articleId");
//$sSql="SELECT * FROM shop_articles WHERE shop_articles.id=".$id." and shop_articles.portalId = ".$portalId;

if (!getParameter($portletUID."_question_submit"))
{
$sSql="UPDATE shop_articles SET countView=countView+1 WHERE id=".$articleId;
$GLOBALS["conn"]->Execute($sSql);
}

$sSql="SELECT DISTINCT
shop_articles.id,
shop_articles.lib_$LANG as lib,
shop_articles.price,
shop_articles.description_$LANG as description,
shop_articles.details_$LANG as details,
shop_articles.availability as availability,
shop_gallery.picture
FROM
shop_articles
INNER JOIN shop_gallery ON shop_articles.id = shop_gallery.articleId
WHERE shop_articles.id=".$articleId." and shop_gallery.default='Y' and
shop_articles.portalId = ".$portalId;

Portal_log($sSql);
$rs=$GLOBALS["conn"]->Execute($sSql);

if ($rs->RecordCount()>0) {

$sSql="SELECT * FROM shop_gallery WHERE articleId=".$articleId;
    $max_quantity=$rs->fields["availability"];

Portal_log($sSql);
$rs_gallery=$GLOBALS["conn"]->Execute($sSql);


	  ?>

	  <div class="articlesview">

	
<div class="images ">
		<div class="image radius5">
<img src="<?php echo getFilesPath("gallery",false)."/".$rs->fields["picture"]; ?>" width="384px" height="449px" />

</div>

 <div id="article_images" class="article_images">
  	  <?php

 while ( !$rs_gallery->EOF)  { 
 	
 	$imgpath=getFilesPath("gallery",false)."/".$rs_gallery->fields["picture"];
		  ?>

		  
		 <a class="min shadowBox" href="<?php echo $imgpath; ?>"> <img src="<?php echo $imgpath; ?>" width="84" height="98" /></a>
		  	  <?php
			
		  $rs_gallery->MoveNext();    
		  }
		  
		 ?>
	
	<div class="zoom" >Cliquez pour agrandir</div>
	 </div> </div>
	
<div class="fiche">
	  <form action="/?pageName=cart" method="POST">
<input type="hidden" value="<?php echo getParameter("articleId"); ?>" name="articleId">
<div class="libelle"><?php echo $rs->fields["lib"]; ?><span class="prix"><?php echo "  ".$rs->fields["price"]; ?> <?php echo $app_shop_currency; ?></span></div>
<hr/>

<b>DESCRIPTION</b>
<div class="description"><?php echo $rs->fields["description"]; ?></div>
<b>DÃ‰TAILS</b>
<div class="details"><?php echo $rs->fields["details"]; ?></div>
<?php 

//getObjByKey("")
?>
<?php if ($app_shop_hasUnit=="yes")
									{ ?>
<b>TAILLES</b>
<table>
<tr>
<?php 

$sSql="SELECT
shop_unit.availability,
shop_sizes.size
FROM
shop_unit
INNER JOIN shop_sizes ON shop_unit.size = shop_sizes.id
WHERE
shop_unit.articleId=".$articleId." AND shop_unit.availability > 0";



Portal_log($sSql);
$rs_size=$GLOBALS["conn"]->Execute($sSql);
while ( !$rs_size->EOF)  {
	?>

		  <td> <div class="size"><input type="radio" name="size" value="<?php echo $rs_size->fields["size"]; ?>" id="size_<?php echo $rs_size->fields["size"]; ?>" /><br/>
		 <?php echo $rs_size->fields["size"]; ?>
		 
		 <script type="text/javascript">
 quantities.push({id:<?php echo $rs_size->fields["size"]; ?>,quantity:<?php echo $rs_size->fields["availability"]; ?>})
  
  </script>
		</div>
</td>
		  	  <?php
		  	  $max_quantity=$rs_size->fields["availability"];			
		  $rs_size->MoveNext();    
		  }
?>
</tr></table>
<br/>
<?php }?>

<b>QUANTITÃ‰</b>
<input type="text" id="quantity" name="quantity" value="1" />&nbsp;fggssd
<?php if ($max_quantity>0) { ?><img src="/images/icons/disponible.gif"/>Disponible en Stock<?php } else { ?><img src="/images/icons/indisponible.gif"/> En rupture de stock<?php } ?>
<br/>
<div>
<input type="submit" value="Ajouter au panier" name="<?php echo $portletUID; ?>submit" class="button"/>
<input type="button" value="Envoyer Ã  un ami" name="<?php echo $portletUID; ?>submit" class="button" onclick="$('#sendtofriend').slideDown();$('#question').hide()"/>
<input type="button" value="Poser une question" name="<?php echo $portletUID; ?>submit" class="button" onclick="$('#question').slideDown();$('#sendtofriend').hide();"/>
</div>
  </form>

<div id="question" class="border">
<form class="std" action="<?php echo createUrl(); ?>" method="POST">
<p class="required text">
			<label for="name">Votre nom</label>
			<?php 
			$_REQUEST[$portletUID."name"]=getUserFullname();
			formText($portletUID."name",0,"account_input"); ?>
			<sup>*</sup>
		</p>
		<p class="required text">
			<label for="mail">Votre mail</label>
			<?php
            if (isset($_SESSION["login"])) $_REQUEST[$portletUID."mail"]=$_SESSION["login"];
			formText($portletUID."mail",0,"account_input"); ?>
			<sup>*</sup>
		</p>
	<p class="required textarea">
			<label for="mail">Question</label>
			<?php formTextArea($portletUID."question",30,5,"account_input"); ?>
			<sup>*</sup>
		</p>
<p >
<label for="" style="color:white">Valider</label>
<input type="submit" value="Valider" name="<?php echo $portletUID; ?>_question_submit" class="button"/>
</p>
</form>

</div>

  <?php if (getParameter($portletUID."_question_submit"))
  {
  	$question=getParameter($portletUID."question");
  	$name=getParameter($portletUID."name");
  	$mail=getParameter($portletUID."mail");
  	$error=false;
  	
  	if ($mail==null || ew_CheckEmail($mail)==FALSE) displayError("Veuillez saisir un email valide !",$portletUID."mail");
  	
  	if ($name==null) displayError("Veuillez saisir votre nom ou le nom de votre société !",$portletUID."name");
  	
  	if ($question==null) displayError("Veuillez saisir une question !",$portletUID."question");
  	
  	if (!$error){
  		echo "<br/><br/>";
  	ShowSuccess("Votre question Ã  bien été enregistrée sur le système, une réponse vous sera envoyée dans les plus bréfs délais.");
  	$sSql="INSERT INTO shop_questions (articleId,question,date,name,mail,portalId) values(".$articleId.",'".$question."','".ew_CurrentDateTime()."','".$name."','".$mail."',".$portalId.")";
  	$GLOBALS["conn"]->Execute($sSql);
  	$msg="Une nouvelle question Ã  été posée sur le site, prière de vous rendre sur la platform de gestion afin d'y répondre.<br/><br>";
  	sendMailToAdmins($portalId, $msg);
  	$msg="Cher ".$name."<br/><br/>";
  	$msg.="Votre question Ã  bien été enregistrée sur le système, une réponse vous sera envoyée dans les plus bréfs délais.";
  	sendMailTo($mail, $msg);
  	}
  }
  
  ?>
  
  <div id="sendtofriend" class="border">
<form class="std" action="<?php echo createUrl(); ?>" method="POST">
<p class="required text">
			<label for="name">Votre nom</label>
			<?php 
			$_REQUEST[$portletUID."name"]=getUserFullname();
			formText($portletUID."name",0,"account_input"); ?>
			<sup>*</sup>
		</p>
		<p class="required text">
			<label for="mail">Votre mail</label>
			<?php
            if (isset($_SESSION["login"])) $_REQUEST[$portletUID."mail"]=$_SESSION["login"];
			formText($portletUID."mail",0,"account_input"); ?>
			<sup>*</sup>
		</p>
		
		<p class="required text">
			<label for="name">Nom de votre ami</label>
			<?php formText($portletUID."friendname",0,"account_input"); ?>
			<sup>*</sup>
		</p>
		<p class="required text">
			<label for="mail">Mail de votre ami</label>
			<?php formText($portletUID."friendmail",0,"account_input"); ?>
			<sup>*</sup>
		</p>
	
<p >
<label for="" style="color:white">Valider</label>
<input type="submit" value="Valider" name="<?php echo $portletUID; ?>_sendtofriend_submit" class="button"/>
</p>
</form>
</div>
 <?php if (getParameter($portletUID."_sendtofriend_submit"))
  {
  	$question=getParameter($portletUID."question");
  	$name=getParameter($portletUID."name");
  	$mail=getParameter($portletUID."mail");
  	$friendname=getParameter($portletUID."friendname");
  	$friendmail=getParameter($portletUID."friendmail");
  	$error=false;
  	
  	if ($mail==null || ew_CheckEmail($mail)==FALSE) displayError("Veuillez saisir un email valide !",$portletUID."mail");
  	
  	if ($name==null) displayError("Veuillez saisir votre nom ou le nom de votre société !",$portletUID."name");
  	
  	if ($friendmail==null || ew_CheckEmail($friendmail)==FALSE) displayError("Veuillez saisir le mail de votre ami !",$portletUID."mail");
  	 
  	if ($friendname==null) displayError("Veuillez saisir le nom de votre ami !",$portletUID."name");
  	 
  	
  	if (!$error){
  		
  		$host=EW_PORTAL_URL;
  		if (isLocal())  $host=getPortalUrl().".betasite.net";
  		
  		echo "<br/><br/>";
  	ShowSuccess("Votre message Ã  bien été envoyée Ã  votre ami.");
  	$msg="<a href='http://".$host."/?pageName=article&articleId=".$articleId."'>Un article</a> vient d'etre envoyé de la part de ".$name." Ã  ".$friendname." ($friendmail) <br/><br>";
  	sendMailToAdmins($portalId, $msg);
  	$msg="Cher ".$friendname."<br/><br/>";
  	$msg.="J'ai trouvé un article suceptible de vous intérésssé sur le site de ".getPortalName()." <br/><br>";
  	$msg.="<a href='http://".$host."/?pageName=article&articleId=".$articleId."'>Cliquez ici</a> pour accéder directement Ã  l'article <br/><br>";
  	$msg.="Votre ami ".$name." <br/><br>";
  	sendMailTo($friendmail, $msg);
  	}
  }
  
  ?>


  
  
</div>

  
  </div>

  <script type="text/javascript">
  $('input[id^="size_"]').change(function() {
	  var id=$(this).attr('id').replace("size_","");
	  $("#quantity").val(1);
	  $("#quantity").spinner("destroy");
	  $("#quantity").spinner({min:1,max:getQuantity(id),stepping: 1});
  });
  $("#quantity").spinner({min:1,max:<?php echo $max_quantity; ?>,stepping: 1});


  $(document).ready(function() {

		/* This is basic - uses default settings */
		
		$("a.min").fancybox();
  });
  </script>
  
<?php }else{
	
	showError("Ce produit n'existe pas, veuillez contacter l'administrateur du site.");
} ?>
  
 